package com.dementors.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dementors.R;


/**
 * ***********************
 * author:Administrator
 * <p/>
 * time:2015/12/3.
 * <p/>
 * name:
 * <p/>
 * step:
 */
public class MyImageView extends LinearLayout implements View.OnClickListener {
    Context context;
    private ImageView imageView_myiv;
    private LinearLayout lloutmyiv;
    private TextView tv_myiv;
    private Bitmap bitmap;
    public  OnLloutCheckedListener listener;

    @Override
    public void onClick(View v) {
        Log.i("oye",v.getId()+"!@#$%");
        if (listener!=null){
            listener.setOnLloutCheckedListener();
        }
    }

    public interface OnLloutCheckedListener{
        void setOnLloutCheckedListener();
    }
    public void setOnLloutCheckedListener(OnLloutCheckedListener listener){
        this.listener=listener;
    }

    public MyImageView(Context context) {
        this(context, null);
    }

    public void setImageView(Bitmap bitmap){
        imageView_myiv.setImageBitmap(bitmap);

    }
    public void setText(String string){
        tv_myiv.setText(string);

    }

    public void setImageView(int res){
        imageView_myiv.setImageResource(res);
    }


    public MyImageView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MyImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context=context;
        LayoutInflater.from(context).inflate(R.layout.myiv,this,true);
        initView();
        bindLisener();//绑定监听器
    }

    private void bindLisener() {
        lloutmyiv.setOnClickListener(this);
//        imageView_myiv.setOnClickListener(this);

    }

    private void initView() {
        imageView_myiv= (ImageView) findViewById(R.id.imageview_myiv);
        tv_myiv= (TextView) findViewById(R.id.tv_myiv);
        lloutmyiv= (LinearLayout) findViewById(R.id.llout_myiv);
    }


}
